package com.ruoyi.logistic.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.logistic.domain.NetworkPackageWeightDifference;
import com.ruoyi.logistic.domain.NetworkPackageWeightDifferenceCollect;
import com.ruoyi.logistic.domain.vo.NetworkPackageWeightDifferenceCollectVo;
import com.ruoyi.logistic.domain.vo.NetworkPackageWeightDifferenceVo;
import com.ruoyi.logistic.enums.NetworkPackageWeightDifferenceCollectEnum;
import com.ruoyi.logistic.enums.NetworkPackageWeightDifferenceEnum;
import com.ruoyi.logistic.mapper.NetworkPackageWeightDifferenceCollectMapper;
import com.ruoyi.logistic.mapper.NetworkPackageWeightDifferenceMapper;
import com.ruoyi.logistic.service.NetworkPackageWeightDifferenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class NetworkPackageWeightDifferenceServiceImpl implements NetworkPackageWeightDifferenceService {
    @Autowired
    private NetworkPackageWeightDifferenceMapper networkPackageWeightDifferenceMapper;
    @Autowired
    private NetworkPackageWeightDifferenceCollectMapper collectMapper;
    @Override
    public List<NetworkPackageWeightDifference> search(NetworkPackageWeightDifferenceVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return networkPackageWeightDifferenceMapper.search(vo);
    }

    @Override
    public List<TableVo> initTable() {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = {"uploadTime","collectPackageNetwork","collectPackageSuperiorsNetwork","inPackageDeliveryNetwork","deliveryNetworkTicket"
                ,"deliveryNetworkInPackageWeight","centreNext","aimProvince","aimCity","inPackageTicket","packageWeight"
                , "inPackageWeight","packageAndInPackageWeight"};
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        for (TableVo vo : list) {
            vo.setTranslate(NetworkPackageWeightDifferenceEnum.getValue(vo.getFields()));
        }
        return list;
    }

    @Override
    public List<NetworkPackageWeightDifferenceCollect> collect(NetworkPackageWeightDifferenceCollectVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return collectMapper.collect(vo);
    }

    @Override
    public List<TableVo> initCollectTable() {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = {"uploadTime", "collectPackageNetwork",  "collectPackageSuperiorsNetwork"
                , "aimProvince", "deliveryNetworkTicket", "inPackageTicket", "packageWeight"
                , "inPackageWeight", "packageAndInPackageWeight"};
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        for (TableVo vo : list) {
            vo.setTranslate(NetworkPackageWeightDifferenceCollectEnum.getValue(vo.getFields()));
        }
        return list;
    }
}
